package com.ff.xyh.consumer.messagedeliver.listener;

import com.ff.xyh.consumer.messagedeliver.controller.MyWebSocket;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author laoliangliang
 * @date 2019/3/29 11:38
 */
//@Component
//@Slf4j
//@ConditionalOnProperty(name="websocket.enabled",havingValue = "true")
public class OrderReceiver implements ChannelAwareMessageListener {

//    @Autowired
//    private MyWebSocket myWebSocket;
//
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
//        byte[] body = message.getBody();
//        log.info("接收到消息:" + new String(body));
//        try {
//            myWebSocket.sendMessage(new String(body));
//        } catch (IOException e) {
//            log.error("send rabbitmq message error", e);
//        }
    }
}
